import java.util.Arrays;
import java.util.Stack;

public class MyStack {
    int[] elem;
    int usedSize;
    public static final  int DEFAULT_SIZE = 10;

    public MyStack() {
        this.elem = new int[DEFAULT_SIZE];
        this.usedSize = 0;
    }

    public int push(int data){
        if(isFull()){
            this.elem = Arrays.copyOf(this.elem, 2*this.elem.length);
            System.out.println("栈满！");
        }
        this.elem[usedSize] = data;
        this.usedSize++;
        return data;
    }

    public int pop(){
        if(isEmpty()){
            return -1;
        }

        return this.elem[--this.usedSize];
    }

    public int peek(){
        if (isEmpty()){
            return -1;
        }

        return this.elem[this.usedSize-1];
    }

    public int size(){
        return this.usedSize;
    }
    public boolean isEmpty(){
        return this.usedSize == 0;
    }

    public boolean isFull(){
        return this.usedSize == elem.length;
    }
}
